package com.yunyike.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yunyike.mapper.RegionMapper;
import com.yunyike.model.Region;
import com.yunyike.service.IRegionService;

/**
 * @author zhengqiang.shi
 * 2015年12月22日 下午4:01:58
 */
@Service("regionServiceImpl")
public class RegionServiceImpl implements IRegionService{

	private Logger log = LoggerFactory.getLogger(RegionServiceImpl.class);

	@Autowired
	private RegionMapper regionMapper;

	public List<Region> findAllProvince() {
		log.info("findAllProvince...");
		return regionMapper.findAllProvince();
	}

	public List<Region> findCityByProvinceId(Integer provinceId) {
		log.info("findCityByProvinceId...");
		return regionMapper.findCityByProvinceId(provinceId);
	}

	public List<Region> findAreaByCityId(Integer cityId) {
		log.info("findAreaByCityId...");
		return regionMapper.findAreaByCityId(cityId);
	}

	public String findProvinceName(Integer provinceId) {
		return regionMapper.selectByPrimaryKey((double)provinceId).getRegionName();
	}

	public String findCityName(Integer cityid) {
		return regionMapper.selectByPrimaryKey((double)cityid).getRegionName();
	}

	public String findAreaName(Integer areaId) {
		return regionMapper.selectByPrimaryKey((double)areaId).getRegionName();
	}
}
